<template>
  <div style="padding: 30px">
    <h4
      style="
        font-weight: 700;
        font-style: normal;
        font-size: 24px;
        color: #344563;
      "
    >
      添加用户
    </h4>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="用户账号">
        <el-input v-model="form.account" placeholder="请输入用户账号"></el-input>
      </el-form-item>
      <el-form-item label="角色">
        <el-select v-model="form.roleName" placeholder="器材库库管">
          <el-option label="系统管理员" value="shanghai"></el-option>
          <el-option label="维修部主管" value="beijing"></el-option>
          <el-option label="维修员" value="beijing"></el-option>
          <el-option label="器材库库管" value="beijing"></el-option>
          <el-option label="调度员" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="用户姓名">
        <el-input v-model="form.userName" placeholder="请输入用户姓名"></el-input>
      </el-form-item>
      <el-form-item label="登录密码">
        <el-input v-model="form.pwd" placeholder="请输入密码"></el-input>
      </el-form-item>
      <el-form-item label="手机号码">
        <el-input v-model="form.phoneNumber" placeholder="请输入手机号码"></el-input>
      </el-form-item>
      <el-form-item label="备注信息">
        <el-input
          type="textarea"
          v-model="form.note"
          placeholder="请输入备注信息"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button>取消</el-button>
        <el-button type="primary" @click="onSubmit">保存</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        account: "",
        roleName: "",
        phoneNumber: "",
        userName: "",
        pwd:'',
        note:''
      },
    };
  },
  methods: {
    onSubmit() {
      console.log("submit!");
    },
   postData:function(){
      this.$axios({
        url:'/user',
        methods:'post',
        data:{
        "account": this.form.account,
        "roleName": this.form.roleName,
        "phoneNumber": this.form.phoneNumber,
        "userName":this.form.userName,
        "pwd":this.form.pwd,
        "note":this.form.note
        }
      }).then((res)=>{
        if(res.data.code==0){
           console.log('cg')
        }else{
          console.log('sb')
        }
      })
    }
  },
  mounted:function(){
    this.postData()
  }
};
</script>